<?php

namespace app\admin\model;

use think\Model;
use app\admin\model\Users;
class Tixian extends Model
{
    // 表名
    protected $name = 'tixian';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'tx_status_text',
        'tx_time_text'
    ];
    
    
    
    public function getTxStatusList()
    {
        return ['0' => __('Tx_status 0'),'2' => __('Tx_status 2'),'1' => __('Tx_status 1')];
    }     


    public function getTxStatusTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['tx_status'];
        $list = $this->getTxStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTxTimeTextAttr($value, $data)
    {
  
        return  date("Y-m-d H:i:s", $value);
    }
    public function getTxTimeAttr($value, $data)
    {
  
        return  date("Y-m-d H:i:s", $value);
    }
    public function getUidAttr($value, $data)
    {
        // return 'aaaa';
        return  (Users::get($value))->user_name;
    }

    protected function setTxTimeAttr($value)
    {
        return $value && !is_numeric($value) ? strtotime($value) : $value;
    }


}
